package com.xzit.tmms.service.teacher;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.xzit.tmms.bean.unit.Teacher;
import com.xzit.tmms.common.exception.ServiceException;
import com.xzit.tmms.common.page.Page;
import com.xzit.tmms.mapper.unit.TeacherMapper;

@Service("teacherService")
public class TeacherServiceImpl implements TeacherService{
	@Resource
	private TeacherMapper teachermapper;

	@Override
	public Page<Map<String, Object>> queryTeacher(Page<Map<String, Object>> page) throws ServiceException {
		teachermapper.queryTeacher(page);
		return page;
	}

	@Override
	public void addTeacher(Teacher teacher) throws ServiceException {
		try {
			teachermapper.save(teacher);
		} catch (Exception e) {
			throw new ServiceException("");
		}
		
	}

	@Override
	public void deleteTeacher(Integer teahcerId) throws ServiceException {
		try {
			teachermapper.delete(teahcerId);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			throw new ServiceException("删除失败");
		}
		
	}

	@Override
	public void updateTeahcer(Teacher teacher) throws ServiceException {
		try {
			teachermapper.update(teacher);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			throw new ServiceException("更新失败");
		}
		
	}

	@Override
	public Teacher getTeacherById(Integer teacherId) throws ServiceException {
		// TODO Auto-generated method stub
		try {
			return teachermapper.getById(teacherId);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			throw new ServiceException("更新失败1");
		}
	}

	@Override
	public List<Map<String, Object>> getTeacherList() throws ServiceException {
		// TODO Auto-generated method stub
		try {
			return teachermapper.getTeacherList();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			throw new ServiceException("查询教师列表失败");
		}
	}
}
